home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8162 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: monkeys.com!not-for-mail
  2. From: rfg@monkeys.com (Ronald F. Guilmette)
  3. Newsgroups: comp.lang.c,comp.lang.c++,gnu.gcc.help,gnu.g++.help,comp.os.msdos.djgpp
  4. Subject: Re: float != float and floats as return types
  5. Date: 15 Feb 1996 01:15:26 -0800
  6. Organization: Infinite Monkeys & Co.
  7. Message-ID: <4futje$6a4@segfault.monkeys.com>
  8. References: <4ej9lb$mpc@fu-berlin.de> <DM04ur.I6u@cwi.nl>
  9. NNTP-Posting-Host: segfault.monkeys.com
  10.  
  11. In article <DM04ur.I6u@cwi.nl>, Dik T. Winter <dik@cwi.nl> wrote:
  12. >In article <4ej9lb$mpc@fu-berlin.de> axl@zedat.fu-berlin.de writes:
  13. > > Hello,
  14. > > I am getting confused, about how C/C++ manage float binary operations,
  15. > > in particular multiplication. The next C++ example gives me surprising
  16. > > results:
  17. >...
  18. > >     float quad( float );
  19. >...
  20. > >         a = i/13.123123;
  21. > >         b = a*a;
  22. > >         c = quad(a);
  23. > >         cout << (b - c) << '\t';
  24. > >         cout << (b - a*a) << '\t';
  25. > >         cout << (c - quad(a)) << '\n';
  26. >
  27. >Declaring a function as returning float does not imply that the actual
  28. >value returned is indeed a float!
  29.  
  30. Yes, it does.
  31.  
  32. Please check the ISO C standard and all relevant Committee responses to
  33. official Defect Reports before making incorrect claims.
  34.  
  35. >In K&R times expressions involving
  36. >floats were calculated using doubles.  Some compilers extended that
  37. >to functions declared as returning float: a double result was returned;
  38. >others did indeed truncate the return value to float.  Thorough
  39. >reading of K&R does not lead to a clear solution here.  In ANSI C both
  40. >are allowed.
  41.  
  42. That is simply untrue.
  43. -- 
  44.  
  45. -- Ron Guilmette, Roseville, CA -------- Infinite Monkeys & Co. ------------
  46. ---- E-mail: rfg@monkeys.com ----------- Purveyors of Compiler Test Suites -
  47. ------ Copyright (c) 1996 by Ronald F. Guilmette; All rights reserved. -----
  48.